x86: limit linear page table use to a single level
authorJan Beulich <jbeulich@suse.com>
Wed, 27 Sep 2017 10:46:52 +0000 (11:46 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 12 Oct 2017 12:44:34 +0000 (14:44 +0200)
commit6987fc7558bdbab8119eabf026e3cdad1053f0e5
tree279569f1d9db9507b8a945b5e2fff5d515bd0d30
parent0d4732ac29b63063764c29fa3bd8946daf67d6f3
x86: limit linear page table use to a single level

That's the only way that they're meant to be used. Without such a
restriction arbitrarily long chains of same-level page tables can be
built, tearing down of which may then cause arbitrarily deep recursion,
causing a stack overflow. To facilitate this restriction, a counter is
being introduced to track both the number of same-level entries in a
page table as well as the number of uses of a page table in another
same-level one (counting into positive and negative direction
respectively, utilizing the fact that both counts can't be non-zero at
the same time).

Note that the added accounting introduces a restriction on the number
of times a page can be used in other same-level page tables - more than
32k of such uses are no longer possible.

Note also that some put_page_and_type[_preemptible]() calls are
replaced with open-coded equivalents.  This seemed preferrable to
adding "parent_table" to the matrix of functions.

Note further that cross-domain same-level page table references are no
longer permitted (they probably never should have been).

This is XSA-240.

Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/domain.c
xen/arch/x86/mm.c
xen/include/asm-x86/domain.h
xen/include/asm-x86/mm.h